package com.hxkj.controller.article;

import com.hxkj.domain.po.Channel;
import com.hxkj.service.article.ChannelService;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultPageStruct;
import com.platform.common.domain.to.PageTo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.Callable;

/**
 * @ClassName ChannelController
 * @Description TODO
 * @Author Mr.zheng
 * @Date 2018/6/7 11:56
 * @Version 1.0
 */
@RestController
@RequestMapping("/channel")
public class ChannelController {

    @Autowired
    private ChannelService channelService;

    /**
    * @Description saveChannel 新增频道
    **/
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public void saveChannel(@ModelAttribute Channel channel) throws Exception{
        channelService.saveChannel(channel);
    }


    /**
    * @Description getChannelList 获取频道列表
    **/
    @RequestMapping(value = "/getlist", method = RequestMethod.POST)
    public Callable<ResultPageStruct<Channel>> getChannelList(@ModelAttribute Channel channel,  @ModelAttribute PageTo pageParam) throws Exception{
        return () -> channelService.getChannelList(channel,pageParam);

    }


    /**
    * @Description getChannel 有条件获取频道
    **/
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    public Callable<ResultDataStruct<Channel>> getChannel(@ModelAttribute Channel channel) throws Exception{
        return null;
    }


    /**
    * @Description removerChannel 删除频道
    **/
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public void removeChannel(@ModelAttribute Channel channel) throws Exception{
        channelService.removeChannel(channel);
    }


    /**
    * @Description modifyChannel 修改频道
    **/
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public void modifyChannel(@ModelAttribute Channel channel) throws Exception{
        channelService.modifyChannel(channel);
    }
}
